﻿using System;
namespace Ex1Student
{
    public class Company
    {
        private string name;
        private string address;
        private int phone;
        private int taxNumber;
        private Person manDirector;

        public Company(string name, string address, int phone, int taxNumber, Person manDirector)
        {
            this.Name = name;
            this.Address = address;
            this.Phone = phone;
            this.TaxNumber = taxNumber;
            this.ManDirector = manDirector;
        }

        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                if (value == null || value == string.Empty || value.Length < 5 || value.Length > 60)
                {
                    throw new InvalidCompanyExeption("Company Name Not valid");
                }
                name = value;
            }
        }

        public string Address
        {
            get
            {
                return address;
            }
            set
            {
                if (value == null || value == string.Empty || value.Length < 10 || value.Length > 100)
                {
                    throw new InvalidPersonExeption("First Name Not valid");
                }
                address = value;
            }
        }

        public int Phone
        {
            get
            {
                return phone;
            }
            set
            {
                if (value.ToString().Length<5)
                {
                    throw new InvalidCompanyExeption("Company telephone number is not full");
                }
                phone = value;
            }
        }

        public int TaxNumber
        {
            get
            {
                return taxNumber;
            }
            set
            {
                if (value.ToString().Length < 5 || value.ToString().Length>10)
                {
                    throw new InvalidCompanyExeption("Tax number is not valid");
                }
                taxNumber = value;
            }
        }

        public Person ManDirector
        {
            get
            {
                return manDirector;
            }
            set
            {
                manDirector = value;
            }
        }
    }

    class InvalidCompanyExeption : ApplicationException
    {
        public InvalidCompanyExeption(string msg)
            : base(msg)
        {

        }
    }

}
